/**
 * 
 */
package com.cwt_taxi_xa.constants;

import com.cwt_taxi_xa.util.AppLog;
import com.cwt_taxi_xa.util.ExceptionUtil;
import com.cwt_taxi_xa.util.Tools;

import android.util.Log;


/**
 * @author wlh
 * 报警标志位
 */
public class ConstantsAram {

	private static final String TAG = "ConstantsAram";

	//	0	1：防劫报警，触动报警开关后触发	收到中心确认后解除
	private static int a0 = 0;
	//	1	1：预警	标志维持至预警条件解除或预警转化成为报警事件
	private static int a1 = 0;
	//	2	1：卫星定位模块发生故障	标志维持至报警条件解除
	private static int a2 = 0;
	//	3	1：卫星定位天线未接或被剪断	标志维持至报警条件解除
	private static int a3 = 0;
	//	4	1：卫星定位天线短路	标志维持至报警条件解除
	private static int a4 = 0;
	//	5	1:终端主电源欠压	标志维持至报警条件解除
	private static int a5 = 0;
	//	6	1:终端主电源掉电	标志维持至报警条件解除
	private static int a6 = 0;
	//	7	1:智能服务终端人机交互设备故障	标志维持至报警条件解除
	private static int a7 = 0;
	//	8	1:语音合成（TTS)模块故障	标志维持至报警条件解除
	private static int a8 = 0;
	//	9	1：摄像头故障	标志维持至报警条件解除
	private static int a9 = 0;
	//	10	1：计价器故障	标志维持至报警条件解除
	private static int a10 = 0;
	//	11	1：服务评价器故障	标志维持至报警条件解除
	private static int a11 = 0;
	//	12	1:LED广告屏故障	标志维持至报警条件解除
	private static int a12 = 0;
	//	13	1:液晶（LCD)显示屏故障	标志维持至报警条件解除
	private static int a13 = 0;
	//	14	1:安全访问模块故障	标志维持至报警条件解除
	private static int a14 = 0;
	//	15	1:LED顶灯故障	标志维持至报警条件解除
	private static int a15 = 0;
	//	16	1:超速报警	标志维持至报警条件解除
	private static int a16 = 0;
	//	17	1:连续驾驶超时	标志维持至报警条件解除
	private static int a17 = 0;
	//	18	1:当天累计驾驶超时	标志维持至报警条件解除
	private static int a18 = 0;
	//	19	1:超时停车	标志维持至报警条件解除
	private static int a19 = 0;
	//	20	1:进出区域/路线	收到应答后清0（终端报三次）
	private static int a20 = 0;
	//	21	1：路段行驶时间不足/过长	收到应答后清0（不实现）
	private static int a21 = 0;
	//	22	1：禁行路段行驶	收到应答后清0（不实现）
	private static int a22 = 0;
	//	23	1：车速传感器故障	标志维持至报警条件解除
	private static int a23 = 0;
	//	24	1：车辆非法点火	收到应答后清0（不实现）
	private static int a24 = 0;
	//	25	1:车辆非法位移	收到应答后清0（不实现）
	private static int a25 = 0;
	//	26	1:智能终端存储异常	标志维持至报警条件解除
	private static int a26 = 0;
	//	27	1:录音设备故障	标志维持至报警条件解除
	private static int a27 = 0;
	//	28	1:支付装置故障	标志维持至报警条件解除
	private static int a28 = 0;
	//	29〜31		预留
	private static int a29 = 0;
	private static int a30 = 0;
	private static int a31 = 0;

	/**
	 * 设置报警值
	 * @param a 设置报警项
	 * @param value 值
	 */
	public static void setAlarmStateValue(int i,int value){

		switch (i) {
		case 0:
			a0=value;
			break;
		case 1:
			a1=value;
			break;
		case 2:
			a2=value;
			break;
		case 3:
			a3=value;
			break;
		case 4:
			a4=value;
			break;
		case 5:
			a5=value;
			break;
		case 6:
			a6=value;
			break;
		case 7:
			a7=value;
			break;
		case 8:
			a8=value;
			break;
		case 9:
			a9=value;
			break;
		case 10:
			a10=value;
			break;
		case 11:
			a11=value;
			break;
		case 12:
			a12=value;
			break;
		case 13:
			a13=value;
			break;
		case 14:
			a14=value;
			break;
		case 15:
			a15=value;
			break;
		case 16:
			a16=value;
			break;
		case 17:
			a17=value;
			break;
		case 18:
			a18=value;
			break;
		case 19:
			a19=value;
			break;
		case 20:
			a20=value;
			break;
		case 21:
			a21=value;
			break;
		case 22:
			a22=value;
			break;
		case 23:
			a23=value;
			break;
		case 24:
			a24=value;
			break;
		case 25:
			a25=value;
			break;
		case 26:
			a26=value;
			break;
		case 27:
			a27=value;
			break;
		case 28:
			a28=value;
			break;
		case 29:
			a29=value;
			break;
		case 30:
			a30=value;
			break;
		case 31:
			a31=value;
			break;

		default:
			break;
		}
	}

	/**
	 * 清除报警值
	 */
	public static void clearAlarmStateValue(){
		a0 =0;
		a1 =0;
		a2 =0;
		a3 =0;
		a4 =0;
		a5 =0;
		a6 =0;
		a7 =0;
		a8 =0;
		a9 =0;
		a10 =0;
		a11 =0;
		a12 =0;
		a13 =0;
		a14 =0;
		a15 =0;
		a16 =0;
		a17 =0;
		a18 =0;
		a19 =0;
		a20 =0;
		a21 =0;
		a22 =0;
		a23 =0;
		a24 =0;
		a25 =0;
		a26 =0;
		a27 =0;
		a28 =0;
		a29 =0;
		a30 =0;
		a31 =0;
	}

	/**
	 * 获取标志位
	 * @return
	 */
	public static byte[] getAlarmStateByte(){

		byte[] alarmstate = new byte[4];
		try {
			//31-24位
			StringBuffer alarmstate0 = new StringBuffer();
			alarmstate0.append(a31);
			alarmstate0.append(a30);
			alarmstate0.append(a29);
			alarmstate0.append(a28);
			alarmstate0.append(a27);
			alarmstate0.append(a26);
			alarmstate0.append(a25);
			alarmstate0.append(a24);
			alarmstate[0] = Tools.BitToByte(alarmstate0.toString());

			//23-16位
			StringBuffer alarmstate1 = new StringBuffer();
			alarmstate1.append(a23);
			alarmstate1.append(a22);
			alarmstate1.append(a21);
			alarmstate1.append(a20);
			alarmstate1.append(a19);
			alarmstate1.append(a18);
			alarmstate1.append(a17);
			alarmstate1.append(a16);
			alarmstate[1] = Tools.BitToByte(alarmstate1.toString());

			//15-8位
			StringBuffer alarmstate2 = new StringBuffer();
			alarmstate2.append(a15);
			alarmstate2.append(a14);
			alarmstate2.append(a13);
			alarmstate2.append(a12);
			alarmstate2.append(a11);
			alarmstate2.append(a10);
			alarmstate2.append(a9);
			alarmstate2.append(a8);
			alarmstate[2] = Tools.BitToByte(alarmstate2.toString());

			//7-0位
			StringBuffer alarmstate3 = new StringBuffer();
			alarmstate3.append(a7);
			alarmstate3.append(a6);
			alarmstate3.append(a5);
			alarmstate3.append(a4);
			alarmstate3.append(a3);
			alarmstate3.append(a2);
			alarmstate3.append(a1);
//			AppLog.e("------------------------------a1:"+a1);
			alarmstate3.append(a0);
//			AppLog.e("------------------------------a0:"+a0);
			alarmstate[3] = Tools.BitToByte(alarmstate3.toString());

			//清除报警
//			clearAlarmStateValue();

		} catch (Exception e) {
			e.printStackTrace();
			AppLog.e(ExceptionUtil.getInfo(e));
		}
		return alarmstate;
	}

}
